home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindlink.net!news
- From: brent_bysouth@mindlink.bc.ca (Brent Bysouth)
- Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
- Subject: Re: C++ with Zapp vs. Delphi
- Date: Fri, 19 Jan 1996 03:14:12 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <4dn30q$o7s@fountain.mindlink.net>
- References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu> <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu>
- NNTP-Posting-Host: line085.nwm.mindlink.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- olczyk@sunphy1 (Jung Oh) wrote:
-
-
- >How do you write a class SortedList which maintains a list of objects which
- >have a method CompareTo. This lists keeps the objects in sorted order based
- >on CompareTo. You also know that
-
- You can do this in Delphi using
-
- a) messaging:
-
- retcode := object.Dispatch(msgCompareTo);
-
- - where msgCompareTo is a message type that you defined, and the
- CompareTo method is declared as message method in the contained
- classes. Note that this is how control components in Delphi handle
- messages from Windows.
-
- b) MethodAddress:
-
- var
- compareTo: TMethod;
- begin
-
- compareTo.Data := object;
- compareTo.Code := object.MethodAddress('CompareTo');
- if compareTo.Code <> nil then
- retcode := TCompareTo(compareTo) ( {params} );
-
- end;
-
- - where TCompareTo is a method type that you define for the CompareTo
- signature. One caveat using this approach: CompareTo must be
- published in the contained classes.
-
-
- -----------
-
- It's not as elegant as other languages (Smalltalk comes to mind), but
- it works. At some time I may be completing a package that makes all
- of this more transparent, but there probably won't be a need as Delphi
- 2.0 apparently supports dynamically typed types...
-
-
- --------------------------------------------------
- brent_bysouth@mindlink.bc.ca
- VB, Delphi & SQL Development
- Vancouver, BC.
- (604) 689-2616
- -------------------------------------------------
-
-